<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Walter+Turncoat&display=swap');

        body {
            font-family: 'Walter Turncoat', cursive;
            background: #f2f2f2;
        }

        .form {
            background: #f2f2f2;
            box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.15);
            border-radius: 30px;
            position: absolute;
            top: 50%;
            left: 50%;
            padding: 20px;
            transform: translate(-50%, -50%);
        }

        input {
            font-family: 'Walter Turncoat', cursive;
            background: #f2f2f2;
            height: 50px;
            width: 300px;
            text-align: center;
            box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.15);
            border: none;
            padding: 3px;
            margin-left: 30px;
            border-radius: 50px;
            font-size: 20px;
        }

        #button {
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 18px;
            margin-top: 30px;
            background: #f2f2f2;
            box-shadow: 0px -6px 10px rgba(255, 255, 255, 1), 0px 4px 15px rgba(0, 0, 0, 0.15);
            border: none;
            width: 130px;
            height: 45px;
            color: black;
            text-align: center;
            cursor: pointer;
            border-radius: 50px;
        }

        .copy {
            margin-left: 85px
        }

        #button:hover {
            box-shadow: inset 5px 6px 10px rgba(255, 255, 255, 0.3), inset -5px 4px 10px rgba(0, 0, 0, 0.15);
        }
    </style>
</head>

<body>
    <div class="form">
        <input placeholder="请生成密码" id="password" readonly>
        <table>
            <th>
                <div id="button" onclick="create()">创建</div>
            </th>
            <th><a id="button" class="copy" onclick="copyPass()">复制</a></th>
        </table>
    </div>
    <script>
        var password = document.getElementById("password");
        function create() {
            var use = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*";
            var lengthx = 10;
            var password = "";
            for (var i = 0; i <= lengthx; i++) {
                var random = Math.floor(Math.random() * use.length);
                password += use.substring(random, random + 1);
            }
            document.getElementById("password").value = password;

        }
        function copyPass() {
            var c = document.getElementById("password");
            c.select();
            document.execCommand("copy");
        }

    </script>
</body>

</html>